<?php
/**
 *
 * User: 梁晓伟  lxw11109@gmail.com
 * Date: 2017-11-05
 * Time: 16:37
 */

namespace App\Http\Controllers\Api\V1\Manager\System;


use App\Http\Controllers\Controller;
use App\Models\About;
use App\Models\Admin;
use App\Models\Brand;
use App\Models\Good;
use App\Models\GoodsOneType;
use App\Models\GoodsTwoType;
use App\Models\IntegralGood;
use App\Models\Message;
use App\Models\MessageUser;
use App\Models\Order;
use App\Models\OrderDetail;
use App\Models\Relation;
use App\Models\Supplier;
use App\Models\UserHome;
use App\Models\UserStatistics;
use App\Models\VipLog;
use DateTime;
use Illuminate\Http\Request;
use Maatwebsite\Excel\Facades\Excel;

class RelationController extends Controller
{

    private $namespace = "App\Http\Controllers\Api\V1\Manager\System\RelationController";

    public function index(Request $request)
    {
        $request = Relation::select()->first();
        return $this->apiResponse($request);
    }

    public function store(Request $request)
    {
        if (!$this->permissionAuthenticate($request->RESOURCE, "这里输入需要的资源组权限")) {
            return $this->apiResponse('', config('errorLiu.NINZHANWUGAIJIEKOUQUANX'));
        }
        $data = $request->only('phone', 'email');
        if (!isset($data['phone']) || !isset($data['email'])) {
            return $this->apiResponse('', config('errorLiu.NOTCANSHUID'));
        }
        Relation::where('id','!=',0)->update($data);
        //添加管理员日志开始
        $url = $this->namespace . "/store";
        $title = "修改";
        $content = "修改了联系我们的内容为【".json_encode($data)."】";
        $this->addAdminLog($request->ADMINID, $request->ADMINUSERNAME, $url, "联系我们模块", $title, $content, $request->getClientIp());
        //添加管理员日志结束
        return $this->apiResponse(true);
    }
}